package com.example.todoapp.http;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Consumer;

public class ResponseStruct {

    private int code;
    private String message;
    private Object data;

    public ResponseStruct(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static ResponseStruct wrap(Consumer<Map<String, Object>> consumer) {
        Map<String, Object> map = new LinkedHashMap<>();
        consumer.accept(map);

        return new ResponseStruct(0, "success", map);
    }

    public static ResponseStruct wrap(Object data) {
        return new ResponseStruct(0, "success", data);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}